﻿using B.S.DataBase.SuYuan.Domains.Entites;
using B.S.DataBase.SuYuan.ErrorCode;
using B.S.DataBase.SuYuan.Infrastructure.Interfaces;
using B.S.DataBase.SuYuan.Read.API.Applications.Commands.Shop;
using MediatR;

namespace B.S.DataBase.SuYuan.Read.API.Applications.CommandHandlers.Shop
{
    public class ShopTypeQueryCommandHandler : IRequestHandler<ShopTypeQueryCommand, APIResult<List<ShopTypeModel>>>
    {
        private readonly IBaseRepository<ShopTypeModel> typeRepo;

        public ShopTypeQueryCommandHandler(IBaseRepository<ShopTypeModel> typeRepo)
        {
            this.typeRepo = typeRepo;
        }


        public Task<APIResult<List<ShopTypeModel>>> Handle(ShopTypeQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ShopTypeModel>> result = new APIResult<List<ShopTypeModel>>();
            result.Code = ResultCode.查询成功;
            result.Msg = ResultCode.查询成功.ToString();
            var list = typeRepo.GetAll();
            result.Data = list.ToList();
            return Task.FromResult(result);



        }





    }
}
